package com.cskaoyan.controller;

import com.cskaoyan.bean.bo.WXGoodListBO;
import com.cskaoyan.bean.vo.*;
import com.cskaoyan.service.WXGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RequestMapping("/wx/goods")
@RestController
public class WXGoodsController {

    @Autowired
    WXGoodsService wxGoodsService;

    @RequestMapping("/count")
    public BaseRespVo count() {
        Map<String, Long> count = wxGoodsService.count( );
        return BaseRespVo.success(count);
    }

    @GetMapping ("/list")
    public BaseRespVo list(WXGoodListBO wxGoodListBO) {
        WXGoodsListVO wxGoodsListVO = wxGoodsService.list(wxGoodListBO);
        return BaseRespVo.success(wxGoodsListVO);
    }

    @RequestMapping("/category")
    public BaseRespVo category(Integer id) {
        WXGoodsCategoryVO wxGoodsCategoryVO = wxGoodsService.category(id);
        return BaseRespVo.success(wxGoodsCategoryVO);
    }

    @RequestMapping("/detail")
    public BaseRespVo detail(Integer id) {
        WXGoodsDetailVO wxGoodsDetailVO = wxGoodsService.detail(id);
        return BaseRespVo.success(wxGoodsDetailVO);
    }

    @RequestMapping("/related")
    public BaseRespVo related(Integer id) {
        WXGoodRelatedListVO relatedListVO = wxGoodsService.related(id);
        return BaseRespVo.success(relatedListVO);
    }
}
